//package com.group.integration.handler;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.group.integration.common.response.ResultResponse;
//import com.group.integration.common.response.ResultResponseFactory;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerExceptionResolver;
//import org.springframework.web.servlet.ModelAndView;
//
//import java.io.IOException;
//
///**
// * 通过接口HandlerExceptionResolver处理异常
// *
// * @author xiaoma
// */
//@Slf4j
//@Component
//public class GlobalExceptionHandlerBack implements HandlerExceptionResolver {
//    @Override
//    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
//        response.addHeader("Content-Type", "application/json;charset=UTF-8");
//        ResultResponse<Object> failedResultOnMessage = ResultResponseFactory.createFailedResultOnMessage(ex.getMessage(), null);
//        try {
//            new ObjectMapper().writeValue(response.getWriter(),failedResultOnMessage);
//            response.getWriter().flush();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        return new ModelAndView();
//    }
//}
